-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cpptest] Use find_package to locate GTest files #9208
Conversation
There is a standard CMake utility for finding GTest, use that instead of doing a manual search. Thanks @tkonolige for the suggestion!
Hi @kparzysz-quic, is it possible to do this for |
I don't know. From what I just googled it seems like GMock is somehow handled by GoogleTest, which is included by the FindGTest routine. |
@Mousius If I understand this thread https://gitlab.kitware.com/cmake/cmake/-/issues/17365 correctly, and the cmake documentation (which says "New in version 3.20: Upstream GTestConfig.cmake is used if possible."), if the version of gtest is new enough (>=1.8) and cmake is new enough (>=3.20) then the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great @kparzysz-quic! It should make finding gtest a lot more reliable. I've left a couple of small changes to make.
Hi @tkonolige, We don't currently use GMock, I have used it as part of #9106 and have updated the CI images to include it with #9107 and #9141. It'd greatly help our ability to write good C++ tests to have GMock setup properly - although I'm only using the headers iirc so it works without referencing I'm also not going to suggest we don't do this until we figure all that out, I had just hoped it'd be easy enough to do 😸 |
Cmake will automatically propagate the interface include directories to the dependends of (in this case) GTest.
@Mousius If we required a recent version of gmock, then we could just use the cmake config it provides. But all versions of Ubuntu seem to not include it, so that approach is out. So unfortunately I think you'll have to write your own |
seems CI is green, let's land this and we can always do the GMock in a follow-on. |
* [cpptest] Use find_package to locate GTest files There is a standard CMake utility for finding GTest, use that instead of doing a manual search. Thanks @tkonolige for the suggestion! * Use GTest:: targets instead of variable * Add USE_GTEST to cmake/config.cmake * Remove GTEST_INCLUDE_DIRS from target_include_directories Cmake will automatically propagate the interface include directories to the dependends of (in this case) GTest. * Restart CI
* [cpptest] Use find_package to locate GTest files There is a standard CMake utility for finding GTest, use that instead of doing a manual search. Thanks @tkonolige for the suggestion! * Use GTest:: targets instead of variable * Add USE_GTEST to cmake/config.cmake * Remove GTEST_INCLUDE_DIRS from target_include_directories Cmake will automatically propagate the interface include directories to the dependends of (in this case) GTest. * Restart CI
* [cpptest] Use find_package to locate GTest files There is a standard CMake utility for finding GTest, use that instead of doing a manual search. Thanks @tkonolige for the suggestion! * Use GTest:: targets instead of variable * Add USE_GTEST to cmake/config.cmake * Remove GTEST_INCLUDE_DIRS from target_include_directories Cmake will automatically propagate the interface include directories to the dependends of (in this case) GTest. * Restart CI
There is a standard CMake utility for finding GTest, use that instead of doing a manual search.
Thanks @tkonolige for the suggestion!